package jehc.djshi.workflow.web;

import io.swagger.annotations.Api;
import jehc.djshi.common.base.BaseAction;
import jehc.djshi.workflow.util.ActivitiUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 流程动态表单
 * @author 邓纯杰
 *
 */
@Api(value = "流程动态表单",  description = "流程动态表单",tags = "流程动态表单")
@RestController
@RequestMapping("/lcDynamicForm")
public class LcDynamicFormController extends BaseAction {
	Logger logger = LoggerFactory.getLogger(this.getClass());
	@Autowired
	ActivitiUtil activitiUtil;


//	/**
//	 *
// 	 * @param lc_deployment_his_id
//	 * @param model
//	 * @return
//	 */
//	@ApiOperation(value="列表页面", notes="列表页面")
//	@RequestMapping(value="/loadLcStartForm",method={RequestMethod.POST, RequestMethod.GET})
//	public ModelAndView startForm(String lc_deployment_his_id, Model model) {
//		ProcessDefinition processDefinition = activitiUtil.getProcessDefinition(lc_deployment_his_id);
//	    Map<String, Map<String, String>> result = Maps.newHashMap();
//	    Map<String,String> datePatterns = Maps.newHashMap();
//	    StartFormData startFormData = activitiUtil.getStartFormData(processDefinition.getId());
//	    List<FormProperty> formProperties = startFormData.getFormProperties();
//	    for (FormProperty formProperty : formProperties) {
//	    	String typeName = formProperty.getType().getName();
//	        if("enum".equals(typeName)){
//	            Map<String, String> values;
//	            values = (Map<String, String>) formProperty.getType().getInformation("values");
//	            if (values != null) {
//	                for (Map.Entry<String, String> enumEntry : values.entrySet())
//	                    logger.debug("enum, key: {}, value: {}", enumEntry.getKey(), enumEntry.getValue());
//	                	result.put("enum_" + formProperty.getId(), values);
//	            	}
//	        }else if("date".equals(typeName)){
//	        	//获取日期格式(String)formProperty.getType().getInformation("datePattern")
//	            datePatterns.put("pattern_"+formProperty.getId(), (String)formProperty.getType().getInformation("datePattern"));
//	            logger.debug("date,key:{},pattern:{}",formProperty.getId(),formProperty.getType().getInformation("datePattern"));
//	        }else if("long".equals(typeName)){
//
//	        }else if("boolean".equals(typeName)){
//
//	        }else if("collection".equals(typeName)){
//
//	        }else{
//	        	//string
//	        }
//	    }
//	    model.addAttribute("datePatterns",datePatterns);
//	    model.addAttribute("result", result);
//	    model.addAttribute("list", formProperties);
//	    model.addAttribute("formData", startFormData);
//	    return new ModelAndView("pc/workflow-view/workflow-dynamic-start-form/workflow-dynamic-start-form-list");
//	}
}
